<div id="panelContribuyente" align="center" class="ui-widget ui-widget-content ui-corner-top" style="width: 1000px;margin: 3px;">
    <div class="ui-widget ui-state-default ui-corner-top ui-title">
        <label>Registro de Declaraci&oacute;n Jurada</label>
    </div>
    <table class="ui-table-panelLayout">
        <tr>
            <td style="width: 55px;">C&oacute;digo:</td>
            <td style="width: 75px;font-weight: bold;"><div id="lblCodigo"><?php echo $this->cidpers; ?></div></td>
            <td style="width: 75px; text-align: right; padding-right: 9px;">Nombre:</td>
            <td style="font-weight: bold;"><div id="lblNombre"><?php echo $this->vnombre; ?></div></td>
            <td style="width: 110px;" align="right" rowspan="2">
            	Declaraci&oacute;n Nro.<br/>
                <div style="font-weight: bold;"><?php echo $this->vnrodoc; ?>
            	<input type="hidden" name="lblIDResumen" id="lblIDResumen" value="<?php echo $this->mhresum; ?>" />
            </td>
        </tr><tr>
            <td>Direcci&oacute;n:</td>
            <td colspan="3" style="font-weight: bold;"><div id="lblDireccion"><?php echo $this->vdirecc; ?></div></td>
        </tr>
    </table>
</div>
<div id="panelControl"  class="ui-widget ui-widget-content ui-corner-bottom" style="width: 1000px;margin: 3px;">
<table width="100%">
<tr>
<td>
<div align="left" style="width:150px;" > 
<button id="btnAuditoriaPredio"  style="height: 25px;"></button>
</div>
</td>
<td>
<div align="right" >     
<button id="btnRegistrarPredio">Registrar</button>
    <button id="btnEditarPredio">Editar</button>
    <button id="btnImprimirPredio">Imprimir</button>
    <button id="btnCancelarPredio">Cancelar</button>
 </div>         
</td>
</tr>
</table>
    
</div>
<div id="panelListaPredio" align="center" style="width: 99%;margin: 3px;">
    <table id="tblListaPredio"></table>
    <div id="tblListaPredio"></div>
</div>
<div id="container" style="display: none; min-width: 400px; height: 150px; margin: 0 auto"></div>
<?php echo $this->util()->getPeriodosDeclaradoCheckBox($this->mhresum); ?>
<script type="text/javascript">
    Persona.ubigeo = <?php echo json_encode($this->rowUbigeo); ?>;

    verPredio = function(rowid, iRow, iCol, e) {
        row = $("#tblListaPredio").jqGrid('getRowData', rowid);
        parameters = {
            "mperson": $("#lblCodigo").text(),
            "vnombre": $("#lblNombre").text(),
            "vdirecf": $("#lblDireccion").text(),
            "mpredio": row.mpredio,
            "mhresum": row.mhresum,
            "cperiod": 'max'
        };

        _post = $.post(path + "registro/verpredio", parameters);
        _post.success(function(request){
            $("#panelRegistro").html(request);
        });
    };
    
    optionPredio = {
        width: 1000,
        height: 300,
        colNames: ['Predio',
            'Direcci\u00F3n',
            'Uso',
            'Uso',
            'Valor del Predio',
            'Valor Afecto',
            'Adquirido',
            'Nro. de Doc.',
            '%',
            'mpredio',
            'tnompob',
            'tnomvia',
            'dnumero',
            'ddepart',
            'dmanzan',
            'dnlotes',
            'mhresum',
            'pestado',
            'mestado',
            'destado'
        ],
        colModel: [{name: 'ccodpre', index:'ccodpre', width: 70, align:'center'},
            {name: 'tnumero', index:'tnumero', width: 450},
            {name: 'vusogen', index:'vusogen', width: 250, hidden: true},
            {name: 'viconos', index:'viconos', width: 55, formatter:imageFormat, unformat:imageUnFormat, align:'center'},
            {name: 'nvalpre', index:'nvalpre', width: 95, formatter:'currency', align: 'right'},
            {name: 'nvalafe', index:'nvalafe', width: 95, formatter:'currency', align: 'right'},
            {name: 'dfecadq', index:'dfecadq', width: 75, formatter:'date', formatoptions: {srcformat:"Y-m-d", newformat:"d/m/Y"}, align: 'center'},
            {name: 'vnrodoc', index:'vnrodoc', width: 75, align: 'center'},
            {name: 'nporcen', index:'nporcen', width: 45, align: 'right'},
            {name: 'mpredio', index:'mpredio', width: 1, hidden: true},
            {name: 'tnompob', index:'tnompob', width: 1, hidden: true},
            {name: 'tnomvia', index:'tnomvia', width: 1, hidden: true},
            {name: 'dnumero', index:'dnumero', width: 1, hidden: true},
            {name: 'ddepart', index:'ddepart', width: 1, hidden: true},
            {name: 'dmanzan', index:'dmanzan', width: 1, hidden: true},
            {name: 'dnlotes', index:'dnlotes', width: 1, hidden: true},
            {name: 'mhresum', index:'mhresum', width: 1, hidden: true},
            {name: 'pestado', index:'pestado', width: 1, hidden: true},
            {name: 'mestado', index:'mestado', width: 1, hidden: true},
            {name: 'destado', index:'destado', width: 1, hidden: true}
        ],
        caption: "&nbsp;&nbsp;&nbsp;Predios Registrados",
        ondblClickRow: verPredio,
        onSelectRow: function(id) {
            row = $(this).getRowData(id);
        },
        gridComplete: function() {
            var _rows = $("#tblListaPredio").find(".jqgrow");
            for (var i = 0; i < _rows.length; i++) {
                if(parseInt(_rows[i].childNodes[19].textContent) == 0) {
                    _rows[i].attributes["class"].value += " nivel5";
                }
            }
        }
    };

    bindkeysPredio = {"onEnter": verPredio};
    
    buscarPredio = function() {         
        parameters = {
            "name": "tblListaPredio",
            "procedure": "pl_function.listar_predios",
            "print": "true",
            "parameters": '{' +
            '"p_mhresum":"' + $("#lblIDResumen").val() + '",' +
            '"p_cidpers":"' + $("#lblCodigo").html() + '"' +
            '}'
        };

        procesarProcedimientoJSON("panelListaPredio", "tblListaPredio", optionPredio, parameters, bindkeysPredio);
    };
    
    $(function(){
        $("#btnImprimirPredio").button({
            icons: {primary: 'ui-icon-calculator'}
        }).bind('click', function() {
            $("#dialogPeriodoCheckBox").dialog("open");
        });
        
        $("#btnDialogPeriodoCheckBoxAceptar").html("Imprimir").button({
            icons: {primary: 'ui-icon-calculator'}
        }).bind('click', function() {
            var cperiod = '';
            $(".chkPnlPeriodo").each(function(){
               if($(this).is(":checked")) {
                   cperiod += (cperiod.length > 0 ? '-' : '');
                   cperiod += $(this).val();
               }
            });

            // # andres # modificado 25/09/2013
            // # antes
            // window.open(pathReport +  "reporte=Report_Completo&opt=p_mhresum^" + $("#lblIDResumen").val() + "|p_cperiod^" + cperiod + "|p_ccodpre^-1|p_mperson^" + $("#lblCodigo").html() + "|p_mostrar_hr^HR|p_mostrar_oi^OI|p_mostrar_pu^PU|p_mostrar_pr^PR", '_blank');
            // # ahora
            var jcheck_hr = '';
            var j_ccodpre = $("#lblCODPredio").val();
            if ($("#check_hr").is(':checked')){
                jcheck_hr = 'HR';
            }
	     //FUERA
           /* window.open( pathReport
                + "reporte=Report_Completo&opt="
                + "p_mhresum^" + $("#lblIDResumen").val()
                + "|p_cperiod^" + cperiod
                + "|p_ccodpre^-1" 
                + "|p_mperson^" + $("#lblCodigo").html()
                + "|p_mostrar_hr^HR"
                + "|p_mostrar_oi^OI"
                + "|p_mostrar_pu^PU"
                + "|p_mostrar_pr^PR", '_blank');
                */
               
               window.open( "http://"+
                    vHostServer+
                    "/git_reporte/declaracionJuradaHR.php?"
                + "p_mhresum=" + $("#lblIDResumen").val()
                + "&p_cperiod=" + cperiod
                + "&p_ccodpre=-1" 
                + "&p_mperson=" + $("#lblCodigo").html()
                + "&usuario=" + P_USER
                + "&p_mostrar_hr=HR"
                + "&p_mostrar_oi=OI"
                + "&p_mostrar_pu=PU"
                + "&p_mostrar_pr=PR", '_blank');
        
        window.open( "http://"+
                    vHostServer+
                    "/git_reporte/declaracionJuradaPU.php?"
                + "p_mhresum=" + $("#lblIDResumen").val()
                + "&p_cperiod=" + cperiod
                + "&p_ccodpre=-1" 
                + "&p_mperson=" + $("#lblCodigo").html()
                + "&usuario=" + P_USER
                + "&p_mostrar_hr=HR"
                + "&p_mostrar_oi=OI"
                + "&p_mostrar_pu=PU"
                + "&p_mostrar_pr=PR", '_blank');
        
            // #

            $("#dialogPeriodoCheckBox").dialog("close");
        });

        $("#btnDialogPeriodoCheckBoxCancelar").button({
            icons: {primary: 'ui-icon-arrowreturnthick-1-w'}
        }).bind('click', function() {
            $("#dialogPeriodoCheckBox").dialog("close");
        });

        $("#dialogPeriodoCheckBox").dialog({
            title: "Seleccione los años a imprimir",
            modal: true,
            minHeight: 'auto',
            width: 250,
            position: ['center', 'center'],
            resizable: false,
            autoOpen: false,
            closeOnEscape: true
        });        
        
        $("#btnRegistrarPredio").button({
            icons: {primary:'ui-icon-document'}
        }).bind('click', function(){
        	parameters = {
            	mperson: $("#lblCodigo").text(),
            	mhresum: "-1", 
                dperson: $("#lblNombre").text() 	
            };
			openDialogData1("registro/declaracion", parameters, "1250", null, "Declaraci&oacute;n Jurada");
		});
		
        $("#btnEditarPredio").button({
            icons: {primary:'ui-icon-pencil'}
        }).bind('click', function(){
            var rowId = $("#tblListaPredio").jqGrid('getGridParam','selrow');

            if(rowId > 0){
                verPredio(rowId);
            }else{
                openDialogError("Seleccione uno de los predios registrados.");
            }

        });
        
        $("#btnCancelarPredio").button({
            icons: {primary:'ui-icon-arrowreturnthick-1-w'}
        }).bind('click', function(){
            location.href = path + "registro";
        });
        
        $("#btnAuditoriaPredio").button({
            icons: {primary:'ui-icon-locked'}
        }).bind('click', function(){
            openDialogDataFunction1("registro/verauditoria?p_nametable=mhresum"+"&p_idsigma=" + $("#lblIDResumen").val() , {}, 500, 230,"Auditoria ");
            
            
        });

        panelPersona({cidpers: $("#lblCodigo").html()});
        buscarPredio();
    });
</script>